#include "apue.h"
#include <stdio.h>
#include <shadow.h>
#include <errno.h>

/**
 * run with super privilege user 
 */
int main(int argc, char *argv[]) {
    if (argc != 2)
        err_quit("Usage: ./a.out <user>");

    struct spwd *sp;
    if ((sp= getspnam(argv[1])) == NULL) {
        if (errno > 0)
            err_sys("getspnam failed");
        err_quit("password of user %s is not exist", argv[1]);
    }

    printf("the encrypt password of user %s is %s.\n", argv[1], sp->sp_pwdp);
    return 0;
}


